package com.csi.bumblebee.controller.backstage;

import com.csi.bumblebee.domain.dictionary.School;
import com.csi.bumblebee.domain.util.MyResult;
import com.csi.bumblebee.domain.util.StateCode;
import com.csi.bumblebee.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 孙伟俊
 */
@RestController
@RequestMapping("/backstage/dictionary/school")
public class BackstageDictionarySchoolController {

    @Autowired
    private SchoolService schoolService;

    /**
     * 展示字典表学校
     * @return MyResult<List<School>>
     */
    @GetMapping("/school")
    public MyResult<List<School>> list(){
        MyResult<List<School>> myResult = new MyResult<>(StateCode.FIND_SUCCESS, "查询成功");

        List<School> list = schoolService.list();
        if (list != null) {
            myResult.setData(list);
        }else {
            myResult.setCode(StateCode.FIND_FAILURE);
            myResult.setMessage("查询失败");
        }
        return myResult;
    }

    /**
     * 更新
     * @param school 对象
     * @return 影响行数
     */
    @PutMapping("/school")
    public MyResult<Integer> update(@RequestBody School school){
        return null;
    }

    /**
     * 增加
     * @param school 对象
     * @return 影响行数
     */
    @PostMapping("/school")
    public MyResult<Integer> add(@RequestBody School school){
        return null;
    }

    /**
     * 删除
     * @param id 主键
     * @return 影响行数
     */
    @DeleteMapping("/{id}")
    public MyResult<Integer> delete(@PathVariable String id){
        return null;
    }

    /**
     * 查询单个
     * @param id 主键
     */
    @GetMapping("/{id}")
    public MyResult<School> listById(@PathVariable String id){
        return null;
    }
}
